package com.zjol

import scala.util.Random

/**
  * Created by Administrator on 2017/3/28.
  */
object PIDemo {


  def main(args: Array[String]): Unit = {

    val Num = 1000000
    var n = 0.0
    for (i <- 1 to Num) {
      val x = Random.nextDouble();
      val y = Random.nextDouble();
      if (x * x + y * y < 1) n += 1;
    }
    println(n * 4 / Num)


  }

}
